home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / SCANDLG.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  106 lines

  1. //--------------------------------------------------------------------
  2. // SCANDLG.AML
  3. // Scan Dialog Box, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro displays a scan dialog box and returns a scan
  6. // 'multistring' with the format: searchstring/files/options. An
  7. // optional list buffer may be passed as arg 3 and an optional dlgbox
  8. // title as arg 4.
  9. //
  10. // Usage:
  11. //
  12. // This macro is intended for use as a utility by other macros, not as a
  13. // standalone macro. Scandlg is used by the Scan and Scan2 macros.
  14. //--------------------------------------------------------------------
  15.  
  16. // compile time macros and function definitions
  17. include bootpath "define.aml"
  18.  
  19. // check if a file list is passed
  20. if bufferflag "d?" (arg 3) then
  21.   passedbuf = arg 3
  22. end
  23.  
  24. title = arg 4
  25.  
  26. // edit fields/groupbox windows
  27. variable f1, f2, g1, g2
  28.  
  29. // retrieve history in scan dlgbox fields and options
  30. function updatehist
  31.   variable searchstr, files, options
  32.   n = splitstr '' (gettext) ref searchstr ref files ref options
  33.  
  34.   // search string
  35.   buffer = getwinbuf f1
  36.   delchar MAX_COL 1 '' buffer
  37.   instext searchstr 1 '' buffer
  38.  
  39.   // files
  40.   if f2 then
  41.     buffer = getwinbuf f2
  42.     delchar MAX_COL 1 '' buffer
  43.     instext (if? files files "*.*")  1 '' buffer
  44.   end
  45.  
  46.   // options
  47.   if not options then
  48.     if n <= 2 then
  49.       options = _SearchOpt
  50.     end
  51.   end
  52.   setgroupbox options "ix"  g1
  53.   setgroupbox options "wu"  g2
  54.   col getlinelen + 1
  55. end
  56.  
  57.  
  58. variable searchstr, filespec, options, options2, delimit
  59.  
  60. // prompt to scan files for a string
  61. if passedbuf or _PromptStyle == 'd' then
  62.   file = getbufname
  63.   dlg = dialog (if? title title "Scan") 66 8 'cp'
  64.   f1 = field "&Search for: >" 3 2  38 '' "_scan"
  65.              whenselect "updatehist"
  66.   if passedbuf then
  67.     filespec = onname (getbufname passedbuf)
  68.     gotowindow dlg
  69.     writestr "In Files:   " + filespec '' 3 4
  70.     gotowindow f1
  71.   else
  72.     f2 = field "In &Files:   >" 3 4  38 (onname (qualify "*.*" file)) "_scan"
  73.                 whenselect "updatehist"
  74.   end
  75.  
  76.   g1 = groupbox '' 3 6
  77.     (menu ''
  78.        item " [ ] &Ignore Case"
  79.        item " [ ] Regular E&Xpression "
  80.      end ) '' _SearchOpt 'ix'
  81.  
  82.   g2 = groupbox '' 29 6
  83.     (if passedbuf then
  84.        menu ''
  85.          item " [ ] &Whole Words        "
  86.        end
  87.      else
  88.        menu ''
  89.          item " [ ] &Whole Words        "
  90.          item " [ ] S&Ubdirectories"
  91.        end
  92.      end) '' _SearchOpt 'wu'
  93.   button "O&k"    56 2 8
  94.   button "Cancel" 56 4 8
  95.   value = if passedbuf then
  96.             getdialog ref searchstr ref options ref options2
  97.           else
  98.             getdialog ref searchstr ref filespec ref options ref options2
  99.           end
  100.   if value == 'Ok' then
  101.     joinstr '' searchstr filespec (options + options2)
  102.   end
  103. else
  104.   ask "[string/files/ixwu] Scan" "_scan"
  105. end
  106.